package com.oxy.model;

import java.io.Serializable;
import java.lang.reflect.Method;

public abstract class BaseDataObject implements Serializable {
	public String toString(){
		StringBuffer retStr = new StringBuffer();
		retStr.append("["+this.getClass()+"]\n");
		Method[] methods = this.getClass().getMethods();
		for(Method item:methods){
			if(item.getName().startsWith("get") && !item.getName().equals("getClass")){
				retStr.append(item.getName()+"()=");
				try {
					Object obj = item.invoke(this);
					if(obj instanceof BaseDataObject){
						retStr.append("\n>>>>>>\n");
						retStr.append(obj.toString());
						retStr.append("<<<<<<\n");
					}
					else{
						if(obj == null) {
							retStr.append("null");
						}
						else {
							retStr.append(obj.toString());
						}
					}
				} catch (Exception e) {
					e.printStackTrace();
					retStr.append(e.getMessage());
				}
				retStr.append("\n");
			}
		}
		return retStr.toString();
	}
}
